package com.example.technologyintroandroid;

import android.graphics.Canvas;
import android.graphics.Color;
import android.view.MotionEvent;
import sheep.game.*;
import sheep.input.TouchListener;

public class GameState extends State implements TouchListener{

	private World gameWorld;
	private GameLayer gameLayer;
	private DebugInfo debugInfo;

	public GameState(int width, int height){
		gameWorld = new World();
		gameLayer = new GameLayer(width, height);
		gameWorld.addLayer(gameLayer);
		debugInfo = new DebugInfo(gameLayer);
	}
	
//	@Override
//	public boolean onTouchDown(MotionEvent event) {
//		switch (event.getAction()) {
//		case MotionEvent.ACTION_DOWN:			
//			float rawX = event.getRawX();
//			float rawY = event.getRawY();
//			float heliX = gameLayer.getHelicopter().getPosition().getX();
//			float heliY = gameLayer.getHelicopter().getPosition().getY();
//			if(rawX>heliX){
//				gameLayer.getHelicopter().setMoveRight(true);
//				gameLayer.getHelicopter().setMoveLeft(false);
//			}else{
//				gameLayer.getHelicopter().setMoveRight(false);
//				gameLayer.getHelicopter().setMoveLeft(true);
//			}
//			if(rawY<heliY){
//				gameLayer.getHelicopter().setMoveUp(true);
//				gameLayer.getHelicopter().setMoveDown(false);
//			}else{
//				gameLayer.getHelicopter().setMoveUp(false);
//				gameLayer.getHelicopter().setMoveDown(true);
//			}
//			break;
//		default:
//			gameLayer.getHelicopter().setAllMoves(false);
//			break;
//		}
//		
//		return true;
//	}
	

	@Override
	public void draw(Canvas canvas){
		canvas.drawColor(Color.BLACK);
		gameWorld.draw(canvas);
		debugInfo.draw(canvas);
	}

	@Override
	public void update(float dt){
		gameWorld.update(dt);
		debugInfo.update(dt);
	}
}
